#include "logo.h"

char *runTo()
{
     char listStr[MAXVALUE];
     char TwordValue[MAXVALUE][MAXLONG] = {"\0"};
     int i;
     int j;
     int k;
     int toParLen =0;
     
     strcpy(listStr,getInput());
     printf("welcome to runTo,list is %s\n",listStr);
     for (i=0;i<toLen;i++)
         printf("%d\n",toPar[i]);
     for (i=0;i<toLen;i++)
     {
         printf("%d\n",toPar[i]);
         printf("%s\n",toName[i][0]);
         if (!strcmp(toName[i][0],listStr))
         {
            toParLen =wordLen;
            for (j=1;j<toPar[i];j++)
             {
                strcpy(toValue[i][j],getValue());
                printf("par value is %s\n",toValue[i][j]);
                for (k=0;k<wordLen;k++)  //to let parameter get value
                {
                    printf("PAR NAME NAME is %s\n",toName[i][j]);
                    printf("WORD NAME NAME is %s\n",wordName[k]);
                    if (!strcmp(wordName[k],toName[i][j]))
                    {
                       strcpy(TwordValue[k],wordValue[k]);
                       strcpy(wordValue[k],toValue[i][j]);
                       printf("%s used to be %s.\n",wordName[k],wordValue[k]);
                       printf("%s  now is %s.\n",wordName[k],toValue[i][j]);
                       goto con;
                    }
                }
                wordLen++;
                strcpy(wordName[wordLen-1],toName[i][j]);
                strcpy(wordValue[wordLen-1],toValue[i][j]);
                con:
                    continue;
             }
            putInput(toValue[i][0]);
            printf("to command is %s\n",toValue[i][0]);
            for (j=0;j<wordLen;j++)
            {
                printf("%d is %s & %s.\n",j,wordName[j],wordValue[j]);
            }
            run();
            for (j=0;j<wordLen;j++)
            {
                printf("%d is %s & %s.\n",j,wordName[j],wordValue[j]);
            }
            for (j=1;j<toPar[i];j++)
            {
                for (k=0;k<wordLen;k++)  //to let parameter putback value
                {
                    if (!strcmp(wordName[k],toName[i][j]))
                    {
                       strcpy(wordValue[k],TwordValue[k]);
                    }
                }
            }
            wordLen =toParLen;
            return toAns;
         }
     }
     
     return 0;
}
